<?php
/**
 * EZ
 * Copyright (c) 2017 http://www.lienze.com All rights reserved.
 * author: EZ <123400558@qq.com>
 * Date: 2017/5/19  Time: 15:51
 */

namespace Admin\Controller;


/**
 * Class CreationDataController
 * @package Admin\Controller
 * 填充数据库
 */
class CreationDataController
{
    public $table;
    public $data;
    public $string;
    public $int;
    public $sum;


    public function creation($index = 1)
    {

        if (empty($this->data) || !is_array($this->data)) {
            die('必须为数组');
        }

        $model = new \Think\Model();

        $dataList = array();

        for ($i = 0; $i < $index; $i++) {
            $dataList[] = $this->data;
        }
        $index = $model ->table($this->table)->data()->addAll($dataList);

        if ($index) {
            return 'success';
        }
    }


    public function string()
    {
        $this->title = '测试文本';
    }

    public function int($min = 0, $max = 6)
    {
        $this->int  = mt_rand($min, $max);
    }
}